package com.igeek.shop.entity;

import java.util.List;

public class PageBeanTwo<T> {

	//当前页
	private int currentPageNumber;
	//每页显示的数据
	private int pageSize;
	//需要查询显示的总共数据条数
	private int totalDataNumber;
	//每页查询的下标
	private int startIndex;
	//总页数
	private int totalPage;
	//初始化开始
	private int start;
	//初始化结束
	private int end;
	//存储所有数据的集合
	private List<T>data;
	//商品类别
	private String cid;
	
	
	
	public String getCid() {
		return cid;
	}



	public void setCid(String cid) {
		this.cid = cid;
	}
	
	
	
	public PageBeanTwo(int currentPageNumber, int pageSize, int totalDataNumber) {
		
		this.currentPageNumber = currentPageNumber;
		this.pageSize = pageSize;
		this.totalDataNumber = totalDataNumber;
		//开始进行页面显示的一些判断
		if(totalDataNumber % pageSize==0){
			totalPage = totalDataNumber/pageSize;
		}else{
			totalPage = totalDataNumber/pageSize+1;
		}
		
		startIndex = (currentPageNumber - 1)*pageSize;
		
		start =1;
		end = 5;
		if(totalPage<=5){
			end = totalPage;
		}else{
			start = currentPageNumber -2;
			end = currentPageNumber+2;
			if(start<=0){
				start =1;
				end = 5;
			}
			if(end>=totalPage){
				start = totalPage - 4;
				end =totalPage;
			}
		}
		
		
		
	}
	
	
	
	public int getCurrentPageNumber() {
		return currentPageNumber;
	}
	public void setCurrentPageNumber(int currentPageNumber) {
		this.currentPageNumber = currentPageNumber;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalDataNumber() {
		return totalDataNumber;
	}
	public void setTotalDataNumber(int totalDataNumber) {
		this.totalDataNumber = totalDataNumber;
	}
	public int getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public int getEnd() {
		return end;
	}
	public void setEnd(int end) {
		this.end = end;
	}
	public List<T> getData() {
		return data;
	}
	public void setData(List<T> data) {
		this.data = data;
	}



	@Override
	public String toString() {
		return "PageBeanTwo [currentPageNumber=" + currentPageNumber + ", pageSize=" + pageSize + ", totalDataNumber="
				+ totalDataNumber + ", startIndex=" + startIndex + ", totalPage=" + totalPage + ", start=" + start
				+ ", end=" + end + ", cid=" + cid + ", data=" + data + "]";
	}
	
	
}
